package com.example.science.controller;


import cn.hutool.core.bean.BeanUtil;
import com.example.science.form.UserRegisterForm;
import com.example.science.param.UserRegisterParam;
import com.example.science.service.UserInfoService;
import com.example.science.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 戴
 * @since 2024年10月21日
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户相关")
public class UserController {
    @Resource
    private UserInfoService userInfoService;
    @PostMapping("/userRegister")
    @ApiOperation("用户注册接口")
    public Result userRegister(@RequestBody UserRegisterForm form)throws Exception{
        userInfoService.userRegister(BeanUtil.toBean(form, UserRegisterParam.class));
        return Result.success("注册成功",null);
    }

    @GetMapping("/sendRegisterCode")
    @ApiOperation("短信验证接口")
    public Result sendRegisterCode(String mobile)throws  Exception {
        userInfoService.sendRegisterCode(mobile);
        return Result.success("成功",null);
    }

}

